<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>

</head>

<body>
  <div id="app">
    <!-- 事件绑定 -->
    <h3>{{ count }}</h3>
    <!-- v-on:事件类型="表达式" -->
    <button @click="addCount">点我+1</button>
    <hr>
    <input type="text" v-model="value" @keydown.enter="addList">
    <button @click="addList">添加</button>
    <ul>
      <li v-for="(v, i) in list">{{ v }}</li>
    </ul>
  </div>

  <script>
    let vm = new Vue({
      // 挂载的节点
      el: '#app',
      // 挂载的数据
      data: {
        count: 1,
        value: '',
        list: ['a', 'b', "哈哈"]
      },
      // 挂载方法
      methods: {
        addCount() {
          // 在方法内  this指向实例
          this.count++
        },
        addList() {
          console.log(this.value);
          this.list.push(this.value)
          this.value = ''
        }
      }
    })
    console.log(vm);
  </script>
</body>

</html>